//查找数的范围
#include<vector>
#include<iostream>
using namespace std;
const int N =1e5+4;
vector<int>arr(N);
int q,n;
//每次询问返回该元素的左右边界
//左
int check1(int num)
{
    int left=0,right=n-1,ans=-1;
    while(left<=right)
    {
        int mid=(right-left)/2+left;
        if(arr[mid]<num) left=mid+1;
        else
        {
            ans=mid;
            right=mid-1;
        }
            
    }
    return arr[ans]==num?ans:-1;
}
//右边界
int check2(int num)
{
    int left=0,right=n-1,ans=-1;
    while(left<=right)
    {
        int mid=(right-left)/2+left;
        if(arr[mid]>num) right=mid-1;
        else
        {
            ans=mid;
            left=mid+1;
        }
            
    }
    return arr[ans]==num?ans:-1;
}
int main()
{
    cin>>n>>q;
    for(int i=0;i<n;i++) cin>>arr[i];
    while(q--)
    {
        int num;cin>>num;
        cout<<check1(num)<<" "<<check2(num)<<endl;
    }
    return 0;
}